package edu.gdpu.memory.metaspace;

/**
 * @author mazebin
 * @date 2021年 07月15日 10:33:16
 *
 * jmap命令的使用 -clstats <pid> 进程id to print class loader statistics
 *  jmap -heap  <pid>
 * 结果：
Heap Configuration:
MinHeapFreeRatio         = 0
MaxHeapFreeRatio         = 100
MaxHeapSize              = 2109734912 (2012.0MB)
NewSize                  = 44040192 (42.0MB)
MaxNewSize               = 703070208 (670.5MB)
OldSize                  = 88080384 (84.0MB)
NewRatio                 = 2
SurvivorRatio            = 8
MetaspaceSize            = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize         = 17592186044415 MB
G1HeapRegionSize         = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
capacity = 24641536 (23.5MB)
used     = 22670688 (21.620452880859375MB)
free     = 1970848 (1.879547119140625MB)
92.00192715259308% used
From Space:
capacity = 524288 (0.5MB)
used     = 0 (0.0MB)
free     = 524288 (0.5MB)
0.0% used
To Space:
capacity = 524288 (0.5MB)
used     = 0 (0.0MB)
free     = 524288 (0.5MB)
0.0% used
PS Old Generation
capacity = 88080384 (84.0MB)
used     = 1142944 (1.089996337890625MB)
free     = 86937440 (82.91000366210938MB)
1.2976146879650297% used

3156 interned Strings occupying 259368 bytes.
 * jmap -clstats <pid>
 * 结果：
class_loader    classes bytes   parent_loader   alive?  type

<bootstrap>     609     1140874   null          live    <internal>
0x0000000082408300      4       5093    0x0000000082408370      live    sun/misc/Launcher$App
ClassLoader@0x000000010000f958
0x0000000082408370      0       0         null          live    sun/misc/Launcher$ExtClassLoa
der@0x000000010000fd00
0x00000000824a4c38      0       0       0x0000000082408300      dead    java/util/ResourceBun
dle$RBClassLoader@0x0000000100063d68

total = 4       613     1145967     N/A         alive=3, dead=1     N/A
*
jstat -gc <pid>
S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCS
U   YGC     YGCT    FGC    FGCT     GCT
512.0  512.0   0.0    0.0   24064.0    0.0     86016.0     1005.0   4864.0 3780.9 512.0  412.
4     155    0.074   0      0.000    0.074
MC:元空间的总大小
 MU：元空间已使用的大小
 */
public class MetaSpaceTest1 {
    public static void main(String[] args) {
        while (true){
            System.out.println("hello world");
        }
    }
    public void method(){
        Object o = new Object();
    }
}
